<juci-layout-with-sidebar>
	<div ng-controller="PagePhoneRingingSchedule">
		<juci-config-section>
			<juci-config-heading>{{ 'Ringing Schedule' | translate }}</juci-config-heading>
			<juci-config-info>{{ 'phone.schedule.info' | translate }}</juci-config-info>
			<juci-config-lines>
				<juci-config-line title="{{'Ringing Schedule'|translate}}">
					<switch name="enabled" ng-model="settings.enabled.value" class="green"></switch>
				</juci-config-line>
				<juci-config-line title="{{'During this time ringing is'|translate}} "  ng-show="settings.enabled.value">
					<juci-select ng-model="settings.status.value" ng-items="enabledDisabledItems" placeholder="{{'Select Schedule Mode'|translate}}"></juci-select>
				</juci-config-line>
			</juci-config-lines>
			<table class="table" ng-show="settings.enabled.value">
				<thead>
					<th translate>Day</th>
					<th translate>Time</th>
					<th translate>Number</th>
					<th translate>Status</th>
					<!--<th translate>Status</th>-->
					<th></th>
					<th></th>
				</thead>
				<tbody>
					<tr ng-repeat="item in schedules">
							<td>{{ item.days.value.join(",") }}</td>
							<td>{{ item.time.value }}</td>
							<td>{{ getAccountName(item) }}</td>
							<td>{{ ((settings.status.value)?"Enabled":"Disabled") | translate}}</td>
							<!--<td>{{ item.enabled.value }}</td>-->
							<td style="width: 1%"><button class="btn btn-default" ng-click="onEditSchedule(item)"><i class="fa fa-pencil" style="{{editColor}}"></i></button></td>
							<td style="width: 1%"><button class="btn btn-default" ng-click="onDeleteSchedule(item)"><i class="fa fa-trash-o"></i></button></td>
					</tr>
					<tr>
							<td colspan="5"></td>
							<td style="width: 1%"><button class="btn btn-default" ng-click="onAddSchedule()"><i class="fa fa-plus"></i></button></td>
					</tr>
				</tbody>
			</table>
		</juci-config-section>
		<juci-config-apply></juci-config-apply>
		<modal title="{{'Add a new Ringing Schedule'|translate}}" ng-show="schedule" on-accept="onAcceptSchedule()" 
			on-dismiss="onDismissSchedule()" dismiss-label="Cancel" accept-label="Save">
			<juci-config-lines>
				<juci-config-line title="{{'Phone Number'|translate}}">
					<juci-select ng-model="schedule.sip_service_provider" ng-items="allSipAccounts" placeholder="{{'Pick Phone Number'|translate}}"/>
				</juci-config-line>
			</juci-config-line>
			<juci-schedule-edit ng-model="schedule" ></juci-schedule-edit>
			<div class="alert alert-danger" ng-show="errors && errors.length"><ul><li ng-repeat="e in errors">{{e|translate}}</li></ul></div>
		</modal>
	</div>
</juci-layout-with-sidebar>
